<?php

namespace app\admin\controller;

use app\common\controller\Backend;
use think\Facade\Db;

/**
 * 活动管理
 */
class Activity extends Backend
{
    /**
     * Activity模型对象
     * @var object
     * @phpstan-var \app\common\model\Activity
     */
    protected object $model;

    protected array|string $preExcludeFields = ['id', 'process', 'create_time', 'update_time'];

    protected string|array $quickSearchField = ['title', 'id'];

    public function initialize(): void
    {
        parent::initialize();
        $this->model = new \app\common\model\Activity();
        $this->request->filter('clean_xss');
    }

    public function export(): void
    {
        if($this->request->isPost()){
            $id = $this->request->post('id');
            $data = Db::name('Baoming')->where('activity_id', $id)->field('name, mobile, company, job')->select();
            if(!empty($data)){
                $this->success('获取成功', $data);
            }else{
                $this->error('暂无数据');
            }
        }
    }

    /**
     * 若需重写查看、编辑、删除等方法，请复制 @see \app\admin\library\traits\Backend 中对应的方法至此进行重写
     */
}